package M;

import java.lang.reflect.Method;

public class Demo2 {

	
	public static void main(String[] args) {
		exe(new Demo2());
	}
	
	
	
	@Auto(ms=1000)
	public void xxx(){
		
		System.out.println("nihao a ");
	}
	
	@Auto(ms=500)
	public void yyy(){
		
		System.out.println("5678767");
	}
	
	public static void exe(final Object obj){
		Class cl = obj.getClass();
		Method[] methods = cl.getDeclaredMethods();
		for (final Method method : methods) {
			Auto auto = method.getAnnotation(Auto.class);
			
			if(auto != null){
				final long ms = auto.ms();
				new Thread(){
					public void run() {
						do{
						try {
							method.invoke(obj, null);
							sleep(ms);
						} catch (Exception e) {
						}
						}while(ms>0);
					};
				}.start();
				
			}
			
		}
	}
	
}
